/**
 * Created by zhangsanfeng on 2021/5/1.
 */

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const state = {
    tabs: [
        {name: '首页', index1: 0, index2: 0, url: '/home', active: true}
    ],
    tabActive: '0-0'
};

const getters = {
    getTabs(state) {
        return state.tabs;
    },
    getTabActive(state) {
        return state.tabActive
    }
};

const mutations = {
    setTabs(state, array) {
        state.tabs = array;
    },
    setTabActive(state, index) {
        state.tabActive = index;
    }
};

const actions = {
    setTabs(context, array) {
        context.commit('setTabs', array);
    },
    setTabActive(context, index) {
        context.commit('setTabActive', index);
    }
};

const store = new Vuex.Store({state, getters, mutations, actions});
export default store;